<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <% String contextPath = request.getContextPath(); 
    request.setAttribute("contextPath", contextPath);%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>推广渠道商统计</title>

    <!-- Bootstrap Core CSS -->
    <link href="${contextPath}/css/bootstrap.min.css" rel="stylesheet">

    <!-- MetisMenu CSS -->
    <link href="${contextPath}/css/metisMenu.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="${contextPath}/css/sb-admin-2.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="${contextPath}/css/font-awesome.min.css" rel="stylesheet" type="text/css">

    <!--common Css-->
    <link href="${contextPath}/css/common.css" rel="stylesheet">
    <link href="${contextPath}/iconfont/iconfont.css" rel="stylesheet">
</head>

<body>

<div id="wrapper">

    <!-- Navigation -->
    <%@include file="nav.jsp"%>

    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h3 class="page-header">推广渠道商统计</h3>
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <!-- /.row -->
        <div class="row">
            <div id="container" style="min-width:400px;height:400px"></div>
        </div>
    </div>
    <!-- /#page-wrapper -->

</div>
<!-- /#wrapper -->

<!-- jQuery -->
<script src="${contextPath}/js/jquery.min.js"></script>

<!-- Bootstrap Core JavaScript -->
<script src="${contextPath}/js/bootstrap.min.js"></script>

<!-- Metis Menu Plugin JavaScript -->
<script src="${contextPath}/js/metisMenu.min.js"></script>

<!-- Custom Theme JavaScript -->
<script src="${contextPath}/js/sb-admin-2.min.js"></script>
<script src="${contextPath}/js/highcharts.js"></script>

<!-- Page-Level Demo Scripts - Tables - Use for reference -->
<script>
    $(function () {
        $('#container').highcharts({
            chart: {
                type: 'column'
            },
            title: {
                text: '推广渠道商金额统计'
            },
            subtitle: {
                text: ''
            },
            credits:{
                enabled: false,
            },
            xAxis: {
                categories: [
                	<%
		               	List<Map<String, String>> list =(List<Map<String, String>>)request.getAttribute("resultDto"); 
		                for(Map<String, String> map:list){
	               	%>
	               	<%="'"+map.get("date")+"',"%>
	                <%
	                }
	                %>
                ],
                crosshair: true
            },
            yAxis: {
                min: 0,
                title: {
                    text: '金额 (元)'
                }
            },
            tooltip: {
                headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
                pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
                '<td style="padding:0"><b>{point.y:.1f} 元</b></td></tr>',
                footerFormat: '</table>',
                shared: true,
                useHTML: true
            },
            plotOptions: {
                column: {
                    pointPadding: 0.2,
                    borderWidth: 0
                }
            },
            <%-- series: [{
                name: '渠道一',
                data: 
                [
                	<%
	               	List<Map<String, String>> list1 =(List<Map<String, String>>)request.getAttribute("resultDto"); 
					String s1="";
					for(int index=0;index<list1.size();index++){
						
						if(index==list1.size()-1){
							s1+=list1.get(index).get("1");
						}else{
	               			s1+=list1.get(index).get("1")+",";
						}
	                }
					%>
					<%=s1%>
                ]
            }, {
                name: '渠道二',
                data: 
                [
                	<%
	               	List<Map<String, String>> list2 =(List<Map<String, String>>)request.getAttribute("resultDto"); 
					String s2="";
					for(int index=0;index<list2.size();index++){
						
						if(index==list2.size()-1){
							s2+=list2.get(index).get("2");
						}else{
	               			s2+=list2.get(index).get("2")+",";
						}
	                }
					%>
					<%=s2%>
                ]
            }, {
                name: '渠道三',
                data: 
                [
                	<%
	               	List<Map<String, String>> list3 =(List<Map<String, String>>)request.getAttribute("resultDto"); 
					String s3="";
					for(int index=0;index<list3.size();index++){
						
						if(index==list3.size()-1){
							s3+=list3.get(index).get("3");
						}else{
	               			s3+=list3.get(index).get("3")+",";
						}
	                }
					%>
					<%=s3%>
                ]
            }] --%>
            series: 
            [
	              
	               <%
	               	List<Map<String, String>> list1 =(List<Map<String, String>>)request.getAttribute("resultDto");
	                Map<String, String> map=list1.get(0);
	                Set<String> keySet=map.keySet();
	                int size = keySet.size();
	                int s=0;
	                for(String str:keySet){
	                	if(str.equals("date")){
	                		continue;
	                	}
	                	s+=1;
	                	if(s<size){
	               %>
			               {
		          			   name: <%="'"+str+"'"%>,
		                       data: 
		                       [
		                       	<%
		       	               	List<Map<String, String>> list2 =(List<Map<String, String>>)request.getAttribute("resultDto"); 
		       					String s2="";
		       					for(int index=0;index<list2.size();index++){
		       						if(index==list2.size()-1){
		       							s2+=list2.get(index).get(str);
		       						}else{
		       	               			s2+=list2.get(index).get(str)+",";
		       						}
		       	                }
		       					%>
		       					<%=s2%>
		                       ]
		          			},
          			
			    	   <%
			           	}else if(s==size){
			           %>
				               {
			         			  name: <%="'"+str+"'"%>,
			                      data: 
			                      [
			                      	<%
			      	               	List<Map<String, String>> list3 =(List<Map<String, String>>)request.getAttribute("resultDto"); 
			      					String s3="";
			      					for(int index=0;index<list3.size();index++){
			      						if(index==list3.size()-1){
			      							s3+=list3.get(index).get(str);
			      						}else{
			      	               			s3+=list3.get(index).get(str)+",";
			      						}
			      	                }
			      					%>
			      					<%=s3%>
			                      ]
			         		  }
	           <%
	                	}
	                }
			   %>
	         ]
        });
    });

</script>

</body>

</html>
